public class SimpleGenericExample4 {

  public static void main(String[] args) {

    new SimpleGeneric<Y>(new Y()).test();
    new SimpleGeneric<Z>(new Z()).test();
  }
}


class SimpleGeneric<T extends X> {

  private T object;

  public SimpleGeneric(T object) {
    this.object = object;
  }

  public void test() {
    this.object.printClass();
  }
}


interface X {

  public void printClass();
}


class Y implements X {

  public void printClass() {
    System.out.println("I am in class Y");
  }
}


class Z implements X {

  public void printClass() {
    System.out.println("I am in class Z");
  }
}
